'use strict';

// Declare app level module which depends on filters, and services
var app = angular.module('app', [
    'ngAnimate',
    'ngCookies',
    'ngStorage',
    'ngSanitize',
    'ui.router',
    'ui.bootstrap',
    'ui.load',
    'ui.jq',
    'ui.validate',
    'app.filters',
    'pascalprecht.translate',
    'app.services',
    'app.directives',
    'app.controllers'
  ])
.run(
  [          '$rootScope', '$state', '$stateParams', 'UserAuth', '$log',
    function ($rootScope,   $state,   $stateParams, UserAuth, $log) {
        $rootScope.$state = $state;
        $rootScope.$stateParams = $stateParams; 
    }
  ]
)
.config(
  [          '$stateProvider', '$urlRouterProvider', '$controllerProvider', '$compileProvider', '$filterProvider', '$provide', '$logProvider', 
    function ($stateProvider,   $urlRouterProvider,   $controllerProvider,   $compileProvider,   $filterProvider,   $provide, $logProvider ) {
        
        // lazy controller, directive and service
        app.controller = $controllerProvider.register;
        app.directive  = $compileProvider.directive;
        app.filter     = $filterProvider.register;
        app.factory    = $provide.factory;
        app.service    = $provide.service;
        app.constant   = $provide.constant;
        app.value      = $provide.value;

        $logProvider.debugEnabled(true);


        $urlRouterProvider
            .otherwise('/dashboard/home');
        $stateProvider 
            .state('login', {
                url: '/login',
                templateUrl: 'page/login/login.html',
                controller: 'LoginController'
            })           
            .state('dashboard', {
                abstract:true,
                url: '/dashboard',
                templateUrl: 'page/app.html'
            })
            .state('dashboard.home', {
                url: '/home',
                templateUrl: 'page/home/home.html',
                controller: 'HomeController',
            })
            
    }
  ]
)
.config(['$translateProvider', function($translateProvider){
  // Register a loader for the static files
  // So, the module will search missing translation tables under the specified urls.
  // Those urls are [prefix][langKey][suffix].
  // $translateProvider.useStaticFilesLoader({
  //   prefix: 'l18n/',
  //   suffix: '.json'
  // });

  // // Tell the module what language to use by default
  // $translateProvider.preferredLanguage('en');

  // // Tell the module to store the language in the local storage
  // $translateProvider.useLocalStorage();

}])

